home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Menus / Low Level / MenuItem.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  2.3 KB  |  97 lines  |  [TEXT/CWIE]

  1. // MenuItem.h
  2.  
  3. #ifndef MenuItem_h
  4. #define MenuItem_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9. #ifndef MenuID_h
  10. #include "MenuID.h"
  11. #endif
  12. #ifndef Str_h
  13. #include "Str.h"
  14. #endif
  15.  
  16. class MenuItem
  17.   {
  18.     private:
  19.         MenuHandle menu;
  20.         uint16 item;
  21.     
  22.         enum SpecialEffect
  23.           {
  24.             noEffect        = 0,
  25.             submenu        = 0x1b,
  26.             script        = 0x1c,
  27.             reducedIcon = 0x1d,
  28.             smallIcon    = 0x1e,
  29.             commandKey    = 0x21
  30.           };
  31.         
  32.         SpecialEffect Effect() const;
  33.  
  34.         bool CanSetEffect( SpecialEffect ) const;
  35.         bool CanClearEffect( SpecialEffect ) const;
  36.         bool CanSetCommandKey() const;
  37.  
  38.         void SetEffect( SpecialEffect );
  39.         void ClearEffect( SpecialEffect );
  40.         
  41.     public:
  42.         MenuItem( MenuHandle theMenu, uint16 theItem )
  43.           : menu( theMenu ),
  44.              item( theItem )
  45.           {}
  46.         
  47.         bool CanEnableIndividually() const            { return item < 31; }
  48.         bool Enabled() const;
  49.         void Enable();
  50.         void Disable();
  51.         void SetEnabled( bool );
  52.         
  53.         void GetText( String255& string ) const    { GetMenuItemText( menu, item, string ); }
  54.         void SetText( ConstPString string );
  55.         void BeDivider()                                    { SetMenuItemText( menu, item, "\p-" ); }
  56.  
  57.         ::Style Style() const;
  58.         void SetStyle( ::Style style )                { SetItemStyle( menu, item, style ); }
  59.         
  60.         uint8 HasMark() const                            { return Mark() != 0; }
  61.         uint8 Mark() const;
  62.         void SetMark( uint8 );
  63.         void RemoveMark()                                    { SetMark( noMark ); }
  64.         void Check()                                        { SetMark( checkMark ); }
  65.         void PartialCheck()                                { SetMark( '-' ); }
  66.         
  67.         bool HasCommandKey() const                        { return Effect() == commandKey; }
  68.         uint8 CommandKey() const;
  69.         void SetCommandKey( uint8 );
  70.         void RemoveCommandKey();
  71.         
  72.         bool HasSubmenu() const                            { return Effect() == submenu; }
  73.         MenuID Submenu() const;
  74.         void SetSubmenu( MenuID );
  75.         void RemoveSubmenu();
  76.  
  77.         bool HasScriptCode() const                        { return Effect() == script; }
  78.         uint8 ScriptCode() const;
  79.         void SetScriptCode( uint8 );
  80.         void RemoveScriptCode();
  81.         
  82.         bool HasIcon() const;
  83.         int16 Icon() const;
  84.         void SetIcon( int16 resource );
  85.         void RemoveIcon();
  86.         
  87.         bool ReducesIcon() const                        { return Effect() == reducedIcon; }
  88.         void ReduceIcon()                                    { SetEffect( reducedIcon ); }
  89.         void DontReduceIcon()                            { ClearEffect( reducedIcon ); }
  90.         
  91.         bool UsesSmallIcon() const                        { return Effect() == smallIcon; }
  92.         void UseSmallIcon()                                { SetEffect( smallIcon ); }
  93.         void DontUseSmallIcon()                            { ClearEffect( smallIcon ); }
  94.   };
  95.  
  96. #endif
  97.